<template>
	<view>
		<scroll ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" :up="upOption" @up="upCallback"
		 @emptyclick="emptyClick">
			<stop isBack>
				<view slot="content">工作量查询</view>
			</stop>
			<!-- <view class="bcf mart3 pad3">
				<view class="list-style-1 marb3 flrc">
					<view class="flex1">工作量类型</view>
					<view class="c12">点击类型添加工作量</view>
				</view>
				<view class="cu-btn line-blue round mar2" v-for="item in types"
				@tap="goto('/pages/ciming/kpi/form_create_user_sales_log?type=' + item.id)">
					{{item.name}}
				</view>
			</view>
			 -->
			<view class="flrc bc13">
				<view class="flex1 pad3">
					<scondition @input="reload()" model="KpiUserSalesLogType" v-model="where.eq.type" label="选择工作量类型"></scondition>
				</view>
				<!-- <view class="flex1 pad3">
					<scondition @input="reload()" model="Job" v-model="where.eq['user.jobs.id']" label="选择岗位"></scondition>
				</view> -->
				
			</view>
			<view class="padlr3">
				<!-- <view class="list-style-1">工作量列表</view> -->
				<view class="pad3 bdbdo flrc pos-r mart3 bcf" 
				v-for="row in data" :key="log.id">
					<view class="flex1 lh2">
						<view class="flrc">
							<view class="fwb fs14 flex1">
								{{row.user.name}} 
							</view>
							<view>
								完成工作量：
								<text class="fs14">{{row.num}}</text>
								<text class="cu-btn sm bg-green marl2 round3" v-if="isbool(row.type)">{{row.type.name}}</text>
							</view>
						</view>
						<view class="mart2 flrc" v-if='isbool(row.customerBookSn)'>
							<view class="flex1">预约码：</view>
							<view>{{row.customerBookSn}}</view>
						</view>
						<view class="flrc c12 fs8 mart2">
							<view>创建时间：</view>
							<view class="flex1">{{datetime(row.createAt)}}</view>
							<view>确认：</view>
							<view>{{row.createBy.name}}</view>
						</view>
						<ripple></ripple>
					</view>
				</view>
			</view>
			<loading :loading="myIsLoading"></loading>
		</scroll>
	</view>
</template>

<script>
	import List from '../../../assets/js/list.js'
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins:[MescrollMixin],
		data() {
			let list = new List()
			return {
				list,
				data:[],
				types:[],
				where:{
					eq:{
						type:''
					}
				}
			}
		},
		methods: {
				reload() {
					this.showLoading()
					this.list.setData({
						_order: {
							id: "DESC"
						},
						_where:this.where,
						_g:['sales',"user"],
						_range:['all']
					}).reload()
				},
				deleteIt(id){
					this.$api.delete('/api/kpiUserSalesLogs/' + id ,{},res=>{
						this.reload()
					})
				}
		},
		mounted() {
			this.list.initMescroll(this).setUrl('/api/kpiUserSalesLogs').setData({
				_order: {
					id: "DESC"
				},
				_where:this.where,
				_g:['sales',"user"],
				_range:['all']
			}).setCbFunc(res => {
				this.data = res
				this.clearLoading()
			}).reload()
		},
		onLoad(option) {
			this.$api.get('/api/kpiUserSalesLogTypes',{
				_order:{
					sort:'ASC'
				}
			},res=>{
				this.log(res)
				this.types = res.d
			})
		},
		onShow() {
			this.list.reload()
		}
	}
</script>

<style>

</style>
